<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld"%>
<f:requestEncoding value="utf-8"/>
<c:import url="header.jsp">
    <c:param name="title" value="Hokejové fórum pro všechny fanoušky"/>
</c:import>
<stripes:useActionBean var="allMessages" binding="/index.action"/>
<div id="messages">
    <table>
        <tr>
            <th>Název</th>
            <th class="response">Odpovědi</th>
            <th class="last-message">Poslední příspěvek</th>
           
        </tr>

        <c:forEach items="${allMessages.list}" var="m" varStatus="loop">
            <c:choose>
                <c:when test="${loop.count % 2 == 0}">
                    <tr class="odd">
                    </c:when>
                    <c:otherwise>
                    <tr>
                    </c:otherwise>
                </c:choose>
                <td class="message-name">
                    <div class="img">
                        <img src="img/i.png" alt="info"/>
                    </div>
                    <div class="forum-name">
                        <h2><a href="forum.action?id=${m.id}">${m.name}</a></h2>
                    </div>
                </td>
                <td class="response">${m.count}</td>
                <td class="last-message"><h3><a href="user.action?id=${m.lastMessage.idUser}">${m.userName}</a></h3><br />${m.lastMessage.postedAt}</td>
                    <c:if test="${sessionScope.user != null}">
                        <c:if test="${sessionScope.user.admin == 1}">
                       
                        <td><a href="forumDelete.action?id=${m.id}">smaž</a></td>
                    </c:if>
                </c:if>
            </tr>
        </c:forEach>

    </table>
</div>
<div id="pagging" class="no-print">
    <p>Strana <a href="#">${allMessages.currentPage}</a> z <a href="index.action?page=${allMessages.countOfPages}">${allMessages.countOfPages}</a> 
        <c:if test="${allMessages.currentPage > 1}">            
            <a href="index.action?page=${allMessages.previousPage}">předchozí</a>
        </c:if>
        <c:if test="${allMessages.currentPage < allMessages.countOfPages}">            
            <a href="index.action?page=${allMessages.nextPage}">další</a>
        </c:if>
        </p>

</div>
<c:import url="footer.jsp">
</c:import>